package com.henry.chatkit.weight.gatherimage

import android.content.Context
import android.graphics.Color
import android.util.AttributeSet

open class SynthesizedImageView : ShadeImageView {

    private lateinit var teamHeadSynthesizer: TeamHeadSynthesizer
    var imageSize = 100
    var synthesizedBg: Int = Color.parseColor("#cfd3d8")
    var defaultImageResId = 0
    var imageGap = 2

    constructor(context: Context?) : super(context) {
        initView()
    }
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
        initView()
    }
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
            context,
            attrs,
            defStyleAttr
    ) {
        initView()
    }

    private fun initView() {
        teamHeadSynthesizer = TeamHeadSynthesizer(context, this)
        teamHeadSynthesizer.setMaxWidthHeight(imageSize, imageSize)
        teamHeadSynthesizer.setDefaultImage(defaultImageResId)
        teamHeadSynthesizer.bgColor = synthesizedBg
        teamHeadSynthesizer.gap = imageGap
    }

    open fun displayImage(imageUrls: List<Any>?): SynthesizedImageView? {
        teamHeadSynthesizer.multiImageData.imageUrls = imageUrls
        return this
    }

    open fun defaultImage(defaultImage: Int): SynthesizedImageView? {
        teamHeadSynthesizer.setDefaultImage(defaultImage)
        return this
    }

    open fun synthesizedWidthHeight(maxWidth: Int, maxHeight: Int): SynthesizedImageView? {
        teamHeadSynthesizer.setMaxWidthHeight(maxWidth, maxHeight)
        return this
    }

    open fun setImageId(id: String) {
        teamHeadSynthesizer.imageId = id
    }

    open fun load() {
        teamHeadSynthesizer.load()
    }

}